package com.example.myproject.redis.redission.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.concurrent.TimeUnit;
@Service
public class RedisOpsKeyClient {
    @Autowired
    private RedisTemplate coredisFrameTemplate;

    public RedisOpsKeyClient() {
    }

    public void delete(String key) {
        this.coredisFrameTemplate.delete(key);
    }

    public void delete(Collection<String> keys) {
        this.coredisFrameTemplate.delete(keys);
    }

    public boolean hasKey(String key) {
        return this.coredisFrameTemplate.hasKey(key);
    }

    public boolean expire(String key, long timeout, TimeUnit timeUnit) {
        return this.coredisFrameTemplate.expire(key, timeout, timeUnit);
    }

    public boolean expire(String key, long timeout) {
        return this.coredisFrameTemplate.expire(key, timeout, TimeUnit.SECONDS);
    }

    public long getExpire(String key) {
        return this.coredisFrameTemplate.getExpire(key);
    }

    public long getExpire(String key, TimeUnit timeUnit) {
        return this.coredisFrameTemplate.getExpire(key, timeUnit);
    }
}
